#from openai import OpenAI
from openai_client_2801 import OpenAI
import dotenv
import os

dotenv.load_dotenv()
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"), base_url=os.getenv("BASE_URL"))
stream = client.chat.completions.create(
    # model='gpt-4o',
    model=os.getenv("MODEL_NAME"),
    messages=[
        {
            "role":"user",
            "content":"帮我分析下过秦论?"
        }
    ],
    stream=True #启动流式输出
)
for chunk in stream:
    if chunk.choices and len(chunk.choices)>0:
        delta_content = chunk.choices[0].delta.content
        if delta_content:
            print(delta_content,end="",flush=True)
